package net.courier.mq.provider.rabbitmq;

import java.io.IOException;

import net.courier.mq.QueuedMessageSendClient;

import com.rabbitmq.client.Channel;

public class RabbitMessageSendClient extends QueuedMessageSendClient {
	private Channel channel;
	private String exchangeName;
	
	protected void sendInternal (String key, byte[] data, boolean mandatory, boolean immediate) {
		try {
			channel.basicPublish(exchangeName, key, mandatory, immediate, null, data);
		} catch (IOException e) {
			throw new MQUnreachableException("发布消息失败", e);
		}
	}
	
	public void setChannel(Channel channel) {
		this.channel = channel;
	}
	
	public void setExchangeName(String exchangeName) {
		this.exchangeName = exchangeName;
	}

}
